<template>
  <!-- <router-view @change-view="onChangeView" /> -->
  <router-view />
  {{store.state.url}}
  <!-- 使用路由来驱动页面的思想 建议使用路由来切换页面，不推荐使用条件渲染显示和隐藏 -->
</template>

<script>
import router from '@/router/index.js'
import store from '@/store'
import { computed, watch } from 'vue'
export default {
  name: 'App',
  setup (props, context) {
    // function onChangeView (event) {
    //   console.log(event)
    //   router.push(event)
    // }
    const routerParams = computed(() => store.state.routerParams)
    watch(routerParams, (newVal, oldVal) => {
      console.log('监听')
      console.log(newVal)
      // router.push({
      //   name: newVal
      // })
      router.push(newVal)
    })
    return {
      // onChangeView
      store
    }
  }
}
</script>

<style>

</style>
